import vec

WIDTH = 250
HEIGHT = 250

BACK_COLOR = (0, 0, 127)
CIRCLE_COLOR = (0, 200, 0)

class MyCircle:
    def __init__(self, pos, r):
        self.pos = pos
        self.r = r

    def Draw(self):
        screen.draw.filled_circle((self.pos.x, self.pos.y), self.r, CIRCLE_COLOR)


def on_key_down(key):
    if key == keys.ESCAPE:
        quit() 
        
def on_mouse_down(pos):
    print("mouse_down", pos)
    
def on_mouse_up(pos):
    print("mouse_up", pos)

start = vec.Vec2(50, 50)
target = vec.Vec2(200, 200)
full_length = (target - start).length()
c = MyCircle(start, 30)
spd = 3
road_dir = target - c.pos
road_dir.normalize()
is_moving = True
move_dir = target - start
move_dir.normalize()

def update():
    global is_moving
    if is_moving == False:
        return

    # move_dir = target - c.pos    
    moved_length = (c.pos - start).length()
    
    if moved_length < full_length:
        c.pos = c.pos + move_dir * spd
    else:
        c.pos = target
        is_moving = False
        
def draw():
    screen.fill(BACK_COLOR)
    c.Draw()
